import 'package:flutter/material.dart';
import 'package:get/get.dart';
import '../../common.dart';

class PaySuccess extends StatefulWidget {
  PaySuccess({super.key});

  @override
  State<PaySuccess> createState() => _WebDetailState();
}

class _WebDetailState extends State<PaySuccess> {
  String? id = '';

  RxMap info = {}.obs;
  getInfo() {
    getData(url: '/order/check', data: {"order_id": '$id'}).then((res) {
      if (res != null) {
        info.value = res;
      }
    });
  }

  @override
  void initState() {
    super.initState();
    id = Get.parameters['id'] ?? Get.parameters['order_id'];
    print(999988888);
    print(id);

    WidgetsBinding.instance.addPostFrameCallback((_) {
      getInfo();
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: [
          Align(
            child: Column(
              children: [
                SizedBox(height: 50),
                Image.asset(
                  'static/web/success.png',
                  width: 75,
                  fit: BoxFit.fitWidth,
                ),
                SizedBox(height: 15),
                Obx(
                  () => Text(
                    '${info['pay_status']}',
                    style: TextStyle(fontSize: 15, color: Color(0XFF0F172B)),
                  ),
                ),
                SizedBox(height: 5),
                Row(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text(
                      '￥',
                      style: TextStyle(fontSize: 12, color: Color(0XFF0F172B)),
                    ),
                    Obx(
                      () => Text(
                        '${info['pay_money_price']}',
                        style: TextStyle(
                          fontSize: 23,
                          color: Color(0XFF0F172B),
                          fontWeight: FontWeight.bold,
                        ),
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 5),
                // Text(
                //   '藏品已发放至您的钱包账户',
                //   style: TextStyle(fontSize: 12, color: Color(0XFF999999)),
                // ),
                SizedBox(height: 20),
              ],
            ),
          ),
          Container(
            padding: EdgeInsets.all(15),
            decoration: BoxDecoration(
              borderRadius: BorderRadius.circular(10),
              color: Color(0XFFF8F9FD),
            ),
            margin: EdgeInsets.symmetric(horizontal: 15),
            child: Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '藏品名称',
                      style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                    ),
                    Obx(
                      () => Text(
                        '${info['title']}',
                        style: TextStyle(
                          fontSize: 14,
                          color: Color(0XFF0F172B),
                        ),
                      ),
                    ),
                  ],
                ),
                // SizedBox(
                //   height: 20,
                // ),
                // Row(
                //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                //   children: [
                //     Text(
                //       '藏品类型',
                //       style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                //     ),
                //     Text(
                //       '超现实元宇宙数字艺术展厅',
                //       style: TextStyle(fontSize: 14, color: Color(0XFF0F172B)),
                //     ),
                //   ],
                // ),
                Divider(color: Color(0XFFDDDDDD), height: 40),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '订单编号',
                      style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                    ),
                    Obx(
                      () => Text(
                        '${info['order_number']}',
                        style: TextStyle(
                          fontSize: 14,
                          color: Color(0XFF0F172B),
                        ),
                      ),
                    ),
                  ],
                ),
                SizedBox(height: 20),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      '购买数量',
                      style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                    ),
                    Obx(
                      () => Text(
                        '${info['total']}',
                        style: TextStyle(
                          fontSize: 14,
                          color: Color(0XFF0F172B),
                        ),
                      ),
                    ),
                  ],
                ),

                // SizedBox(
                //   height: 20,
                // ),
                // Row(
                //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                //   children: [
                //     Text(
                //       '购买时间',
                //       style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                //     ),
                //     Text(
                //       'FF239048902345',
                //       style: TextStyle(fontSize: 14, color: Color(0XFF0F172B)),
                //     ),
                //   ],
                // ),
                // SizedBox(
                //   height: 20,
                // ),
                // Row(
                //   mainAxisAlignment: MainAxisAlignment.spaceBetween,
                //   children: [
                //     Text(
                //       '支付方式',
                //       style: TextStyle(fontSize: 14, color: Color(0XFF999999)),
                //     ),
                //     Text(
                //       'FF239048902345',
                //       style: TextStyle(fontSize: 14, color: Color(0XFF0F172B)),
                //     ),
                //   ],
                // ),
              ],
            ),
          ),
          SizedBox(height: 20),
          GestureDetector(
            onTap: () {
              Get.toNamed('/user/order_list?type=1');
            },
            child: Container(
              margin: EdgeInsets.symmetric(horizontal: 15),
              height: 60,
              alignment: Alignment.center,
              decoration: BoxDecoration(
                color: Color(0XFF0F172B),
                borderRadius: BorderRadius.circular(60),
              ),
              child: Text(
                '确认',
                style: TextStyle(color: Color(0XFFFFFFFF), fontSize: 18),
              ),
            ),
          ),
        ],
      ),
    );
  }
}
